﻿using JetBrains.Annotations;
using Mod.Search.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Mod.Search.Handlers
{
    [UsedImplicitly]
    public class SearchSiteSettingsHandler : ContentHandler
    {
        public SearchSiteSettingsHandler(IRepository<SearchSiteSettingsRecord> repository)
        {
            T = NullLocalizer.Instance;
            Filters.Add(new ActivatingFilter<SearchSiteSettings>("Site"));
            
            Filters.Add(StorageFilter.For(repository));
        }

        public Localizer T { get; set; }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Search")));
        }

    }
}